package com.topscomm.main.config;

import com.topscomm.basic.util.Config;
import com.topscomm.cbo.service.ICboMessageAppService;
import com.topscomm.cbo.service.ICboMessageSysService;
import com.topscomm.tap.service.ITapPasswordService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.remoting.caucho.HessianProxyFactoryBean;

@Configuration
public class HessianConfig {

	@Bean
	@Primary
	public HessianProxyFactoryBean cboMessageAppService() {
		HessianProxyFactoryBean factoryBean = new HessianProxyFactoryBean();
		factoryBean.setConnectTimeout(3000);
		factoryBean.setReadTimeout(200000);
		factoryBean.setOverloadEnabled(true);
		factoryBean.setUsername("admin");
		factoryBean.setPassword("admin");
		factoryBean.setServiceUrl(Config.getInstance().getValue("TopscommServerUrl", "") + "/misHessian/cboMessageAppService");
		factoryBean.setServiceInterface(ICboMessageAppService.class);
		return factoryBean;
	}

	@Bean
	@Primary
	public HessianProxyFactoryBean cboMessageSysService() {
		HessianProxyFactoryBean factoryBean = new HessianProxyFactoryBean();
		factoryBean.setConnectTimeout(3000);
		factoryBean.setReadTimeout(100000);
		factoryBean.setOverloadEnabled(true);
		factoryBean.setUsername("admin");
		factoryBean.setPassword("admin");
		factoryBean.setServiceUrl(Config.getInstance().getValue("TopscommServerUrl", "") + "/misHessian/cboMessageSysService");
		factoryBean.setServiceInterface(ICboMessageSysService.class);
		return factoryBean;
	}

	@Bean
	@Primary
	public HessianProxyFactoryBean cboUserPwdService() {
		HessianProxyFactoryBean factoryBean = new HessianProxyFactoryBean();
		factoryBean.setConnectTimeout(3000);
		factoryBean.setReadTimeout(10000);
		factoryBean.setOverloadEnabled(true);
		factoryBean.setUsername("admin");
		factoryBean.setPassword("admin");
		factoryBean.setServiceUrl(Config.getInstance().getValue("TopscommUipUrl", "") + "/misHessian/cboUserPwdService");
		factoryBean.setServiceInterface(ITapPasswordService.class);
		return factoryBean;
	}

}
